// 给n个数的数组和一个数字k，返回出现大于n/k的数字。空间复杂度O(n/k)、时间复杂度O(n)
function fun(n, k) {
    const count = n.length/k
    const map = new Map()

    for(let i =0; i<n.length; i++) {
        const k = (map.get(n[i]) || 0) + 1
        // console.log(k)
        map.set(n[i],k)
    }

    const keys = map.keys()
    
    const result = []
    for(key of keys){
        // console.log(key,map[key])
        if(map.get(key)>count) result.push(key)
    }

    return result
}

const arr = [1,1,4,2,1,4,2,2,4,2]
console.log(fun(arr,5))